<template>
  <div>
    <!-- 头部 -->
    <header class="w100pc fixed">
      <div class="fcc address mb-10">
        <h3>深圳</h3>
        <i class="iconfont iconxiala"></i>
      </div>
      <div class="fcc input rel f12">
        <input type="text" placeholder="搜索城市/目的地">
        <i class="iconfont iconxiaoxi- abs"></i>
      </div>
      <div class="flex f14 fff ml-10 mt-20 mr-10 wrap">
        <h6>周边城市:</h6>
        <ul class="flex f14 fff index">
          <li class="ml-10 li">深圳</li>
          <li class="ml-10 li">惠州</li>
          <li class="ml-10 li">广州</li>
          <li class="ml-10 li">清远</li>
          <li class="ml-10 li">河源</li>
          <li class="ml-10 li">江门</li>
          <li class="ml-10 li">厦门</li>
          <li class="ml-10 li">三亚</li>
          <li class="ml-10 li">三亚</li>
        </ul>
      </div>
    </header>

    <!-- 景点列表 -->
    <van-list
      class="ul"
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <li v-for="item in list" :key="item.index" @click="toGoods(item.sceneryId)">
        <div class="rel">
          <img
            v-lazy="`https://img.villaday.com${item.imageURL}`"
            width="100%"
            height="175px"
            class="rel"
          >
          <div class="pirce fcc abs">
            <span class="f12 fff">￥</span>
            <h6 class="fff">{{item.displayPrice}}</h6>
            <span class="f12 fff">起</span>
          </div>
        </div>
        <div class="text bg-fff">
          <h6 class="f14 lh15">{{item.name}}</h6>
          <p class="f12 mb-5 lh15">{{item.desc}}</p>
          <p class="area fcc fff pl-10 pr-10 mt-5">
            <i class="iconfont iconlocation f12"></i>
            <span class="f12">{{item.address}}</span>
          </p>
        </div>
      </li>
    </van-list>

    <!-- 底部 -->
    <Footer page="address"></Footer>
  </div>
</template>

<script>
import Footer from "../components/Footer";
export default {
  data() {
    return {
      list: [],
      loading: false,
      pageNum: 1,
      pageSize: 2,
      totalPge: "",
      finished: false
    };
  },
  components: {
    Footer
  },
  methods: {
    //上拉加载 分页
    onLoad() {
      setTimeout(() => {
        let url = "/scenery/getList";
        let data = {
          pageNum: this.pageNum,
          pageSize: this.pageSize
        };
        this.$axios
          .post(url, data)
          .then(res => {
            // console.log(res, "res");
            this.totalPge = res.totalPge;
            //不能给数组里面push数组
            res.list.forEach(lists => {
              this.list.push(lists);
            });
            // 数据全部加载完成
            if (res.list <= this.pageSize) {
              this.finished = true;
            }
          })
          .then(() => {
            // console.log(this.pageNum);

            this.pageNum++; //页数增替
            // console.log(this.list);

            // 加载状态结束
            this.loading = false;
          });
      }, 500);
    },
    toGoods(sceneryId) {
      this.$router.push({ name: "goodsList", params: { sceneryId } });
    }
  }
};
</script>

<style lang="less" scoped>
@import "../style/address.less";
</style>

